package org.kimoji.show.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.kimoji.entity.Album;
import org.kimoji.entity.Category;
import org.kimoji.entity.biz.ItemBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class ShowDAO {
	
	@Autowired
	private SqlSession sqlSession;
	
	public List<ItemBiz> getItemByIds(int[] ids){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ids", ids);
		return sqlSession.selectList("ItemMapper.getItemByIds", params);
	}
	
	public ItemBiz getItemById(boolean isDetail ,String id){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		return sqlSession.selectOne(isDetail?"ItemMapper.getItemByIdForDetail":"ItemMapper.getItemByIdForDialog", params);
	}
	
	public List<Category> getCategory(){
		return sqlSession.selectList("ItemMapper.getCategory");
	}
	
	public List<Album> getAlbumByIds(int[] ids){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("ids", ids);
		return sqlSession.selectList("AlbumMapper.getAlbumByIds",params);
	}
	
	public Album getAlbumById(int id){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		return sqlSession.selectOne("AlbumMapper.getAlbumById",params);
	}
}
